home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb11.zip / LIST2.PAS < prev    next >
Pascal/Delphi Source File  |  1985-07-13  |  1KB  |  35 lines

  1. PROGRAM List;
  2.  
  3. {
  4. This program will list any text file, including Pascal
  5. files, on a printer.
  6.  
  7. Source: "COPY and LIST for Pascal Source Files", TUG Lines Volume I Issue 6
  8. Author: Harold Drake
  9. Application: All systems
  10. }
  11.  
  12. var
  13.   fname:     string[14];             {name of file to be listed}
  14.   line:      string[80];             {one line of the file}
  15.   n:         integer;                {index variable}
  16.   lgth:      integer;                {length of filename string}
  17.   f:         text;                   {internal filename}
  18.   pascal:    boolean;                {flag for pascal file extension}
  19. begin
  20.   write('Enter file name:  ');    readln(fname);
  21.   pascal  :=true;
  22.   lgth :=length(fname);
  23.   for n :=1 to lgth do if fname[n] ='.' then pascal := false;
  24.   if pascal then insert('.PAS',fname,1+lgth);
  25.   if (not pascal) and (fname[lgth] = '.') then delete(fname,lgth,1);
  26.   assign(f,fname);
  27.   reset(f);
  28.   while not eof(f) do
  29.     begin
  30.       readln(f,line);
  31.       writeln(lst,line);
  32.     end;
  33.   close(f);
  34.   write(lst,chr(12));
  35. end.